/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

/**
 *
 * @author Wx
 */
@Entity
public class Credit implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String remark;
    private Double creditScore; //paymentScore + outstandingScore + relationshipScore
    private String creditRank; //Bronze, Silver, Gold, Platinum, Titanium
    private Double creditLimit;
    private Double creditRate;
    private Double deposit;
    private Double balance;
    @OneToMany(cascade = {CascadeType.PERSIST}, fetch = FetchType.EAGER)
    private List<Invoice> invoices = new ArrayList<Invoice>();
    //40% of creditScore
    private Double paymentScore;
    private Integer totalPayments;
    private Integer paymentsPaidLessThan30;
    private Integer paymentsPaidLate30to59; //20% weightage of paymentScore
    private Integer paymentsPaidLate60to89; //30% weightage of paymentScore
    private Integer paymentsPaidLaterThan90; //50% weightage of paymentScore
    //40% of creditScore
    private Double outstandingScore;
    private Double totalAmount;
    private Double accountsPayable;
    //20% of creditScore
    private Double relationshipScore;
    private Integer yearsInBusiness;
    private Integer yearsOfDealings;

    public Credit() {
    }

    public Credit(String remark, Double creditScore, String creditRank, Double paymentScore, Integer totalPayments, Integer paymentsPaidLessThan30,
            Integer paymentsPaidLate30to59, Integer paymentsPaidLate60to89, Integer paymentsPaidLaterThan90, Double outstandingScore,
            Double totalAmount, Double accountsPayable, Double relationshipScore, Integer yearsInBusiness, Integer yearsOfDealings,
            Double creditLimit, Double deposit, Double balance, List<Invoice> invoices, Double creditRate) {
        this.remark = remark;
        this.creditScore = creditScore;
        this.creditRank = creditRank;
        this.paymentScore = paymentScore;
        this.totalPayments = totalPayments;
        this.paymentsPaidLessThan30 = paymentsPaidLessThan30;
        this.paymentsPaidLate30to59 = paymentsPaidLate30to59;
        this.paymentsPaidLate60to89 = paymentsPaidLate60to89;
        this.paymentsPaidLaterThan90 = paymentsPaidLaterThan90;
        this.outstandingScore = outstandingScore;
        this.totalAmount = totalAmount;
        this.accountsPayable = accountsPayable;
        this.relationshipScore = relationshipScore;
        this.yearsInBusiness = yearsInBusiness;
        this.yearsOfDealings = yearsOfDealings;
        this.creditLimit = creditLimit;
        this.deposit = deposit;
        this.balance = balance;
        if (invoices != null) {
            this.invoices = invoices;
        } else {
            this.invoices = null;
        }
        this.creditRate = creditRate;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the remark
     */
    public String getRemark() {
        return remark;
    }

    /**
     * @param remark the remark to set
     */
    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * @return the creditScore
     */
    public Double getCreditScore() {
        return creditScore;
    }

    /**
     * @param creditScore the creditScore to set
     */
    public void setCreditScore(Double creditScore) {
        this.creditScore = creditScore;
    }

    /**
     * @return the creditRank
     */
    public String getCreditRank() {
        return creditRank;
    }

    /**
     * @param creditRank the creditRank to set
     */
    public void setCreditRank(String creditRank) {
        this.creditRank = creditRank;
    }

    /**
     * @return the paymentScore
     */
    public Double getPaymentScore() {
        return paymentScore;
    }

    /**
     * @param paymentScore the paymentScore to set
     */
    public void setPaymentScore(Double paymentScore) {
        this.paymentScore = paymentScore;
    }

    /**
     * @return the totalLoans
     */
    public Integer getTotalPayments() {
        return totalPayments;
    }

    /**
     * @param totalLoans the totalLoans to set
     */
    public void setTotalPayments(Integer totalPayments) {
        this.totalPayments = totalPayments;
    }

    /**
     * @return the loansPaidLessThan29
     */
    public Integer getPaymentsPaidLessThan30() {
        return paymentsPaidLessThan30;
    }

    /**
     * @param loansPaidLessThan29 the loansPaidLessThan29 to set
     */
    public void setPaymentsPaidLessThan30(Integer paymentsPaidLessThan30) {
        this.paymentsPaidLessThan30 = paymentsPaidLessThan30;
    }

    /**
     * @return the loansPaidLate30to59
     */
    public Integer getPaymentsPaidLate30to59() {
        return paymentsPaidLate30to59;
    }

    /**
     * @param loansPaidLate30to59 the loansPaidLate30to59 to set
     */
    public void setPaymentsPaidLate30to59(Integer paymentsPaidLate30to59) {
        this.paymentsPaidLate30to59 = paymentsPaidLate30to59;
    }

    /**
     * @return the loansPaidLate60to89
     */
    public Integer getPaymentsPaidLate60to89() {
        return paymentsPaidLate60to89;
    }

    /**
     * @param loansPaidLate60to89 the loansPaidLate60to89 to set
     */
    public void setPaymentsPaidLate60to89(Integer paymentsPaidLate60to89) {
        this.paymentsPaidLate60to89 = paymentsPaidLate60to89;
    }

    /**
     * @return the loansPaidLaterThan90
     */
    public Integer getPaymentsPaidLaterThan90() {
        return paymentsPaidLaterThan90;
    }

    /**
     * @param loansPaidLaterThan90 the loansPaidLaterThan90 to set
     */
    public void setPaymentsPaidLaterThan90(Integer paymentsPaidLaterThan90) {
        this.paymentsPaidLaterThan90 = paymentsPaidLaterThan90;
    }

    /**
     * @return the outstandingScore
     */
    public Double getOutstandingScore() {
        return outstandingScore;
    }

    /**
     * @param outstandingScore the outstandingScore to set
     */
    public void setOutstandingScore(Double outstandingScore) {
        this.outstandingScore = outstandingScore;
    }

    /**
     * @return the totalAmount
     */
    public Double getTotalAmount() {
        return totalAmount;
    }

    /**
     * @param totalAmount the totalAmount to set
     */
    public void setTotalAmount(Double totalAmount) {
        this.totalAmount = totalAmount;
    }

    /**
     * @return the outstandingAmount
     */
    public Double getAccountsPayable() {
        return accountsPayable;
    }

    /**
     * @param outstandingAmount the outstandingAmount to set
     */
    public void setAccountsPayable(Double accountsPayable) {
        this.accountsPayable = accountsPayable;
    }

    /**
     * @return the relationshipScore
     */
    public Double getRelationshipScore() {
        return relationshipScore;
    }

    /**
     * @param relationshipScore the relationshipScore to set
     */
    public void setRelationshipScore(Double relationshipScore) {
        this.relationshipScore = relationshipScore;
    }

    /**
     * @return the yearsInBusiness
     */
    public Integer getYearsInBusiness() {
        return yearsInBusiness;
    }

    /**
     * @param yearsInBusiness the yearsInBusiness to set
     */
    public void setYearsInBusiness(Integer yearsInBusiness) {
        this.yearsInBusiness = yearsInBusiness;
    }

    /**
     * @return the yearsOfDealings
     */
    public Integer getYearsOfDealings() {
        return yearsOfDealings;
    }

    /**
     * @param yearsOfDealings the yearsOfDealings to set
     */
    public void setYearsOfDealings(Integer yearsOfDealings) {
        this.yearsOfDealings = yearsOfDealings;
    }

    /**
     * @return the creditLimit
     */
    public Double getCreditLimit() {
        return creditLimit;
    }

    /**
     * @param creditLimit the creditLimit to set
     */
    public void setCreditLimit(Double creditLimit) {
        this.creditLimit = creditLimit;
    }

    /**
     * @return the deposit
     */
    public Double getDeposit() {
        return deposit;
    }

    /**
     * @param deposit the deposit to set
     */
    public void setDeposit(Double deposit) {
        this.deposit = deposit;
    }

    /**
     * @return the balance
     */
    public Double getBalance() {
        return balance;
    }

    /**
     * @param balance the balance to set
     */
    public void setBalance(Double balance) {
        this.balance = balance;
    }

    /**
     * @return the payments
     */
    public List<Invoice> getInvoices() {
        return invoices;
    }

    /**
     * @param payments the payments to set
     */
    public void setInvoices(List<Invoice> invoices) {
        this.invoices = invoices;
    }

    /**
     * @return the creditRate
     */
    public Double getCreditRate() {
        return creditRate;
    }

    /**
     * @param creditRate the creditRate to set
     */
    public void setCreditRate(Double creditRate) {
        this.creditRate = creditRate;
    }
}
